package collection.Demo02;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 * @Author Miku
 * @Create 2021/4/12 15:10
 */
public class Test {
    public static void main(String[] args) {
        //新建Collection对象
        Collection collection = new ArrayList();
        Student s1 = new Student("张三", 20);
        Student s2 = new Student("李四", 21);
        Student s3 = new Student("王五", 22);

        collection.add(s1);
        collection.add(s2);
        collection.add(s3);

        System.out.println("元素个数:"+collection.size());
        System.out.println(collection);

        Iterator it = collection.iterator();
        while (it.hasNext()) {
            System.out.println(it.next());
        }

    }
}
